<template>
  <div class="home">
    
     <h3>HOME --- {{$store.state.zhang.name}} </h3>
     <h4>
       计算属性 {{$store.getters["zhang/newName"] }}
     </h4>
      <button @click="changeName">点我修改</button>
        <div>
         <button @click="initAsync" >发起异步</button>
        </div>
  </div>
</template>

<script>
// @ is an alias to /src 


export default {
  name:"Home",      
  created() {
    console.log(this.$store);
  },
  methods: {
    changeName() {
      // 开启命名空间 要加模块名
      this.$store.commit("zhang/CHANGE_NAME")
    },
    initAsync() {
      this.$store.dispatch("zhang/init")
    }
  }
}
</script> 
  